package boot.common;

public class CommonResult<T>{
    private Integer code;
    private String message;
    private T data;

    public CommonResult() {
    }

    public CommonResult(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Integer getCode() {

        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public T getData() {
        return data;
    }

    public static CommonResult success(){
        CommonResult result=new CommonResult();
        result.setCode(200);
        result.setMessage("成功");
        return result;
    }

    public static <T> CommonResult<T> success(T data){
        CommonResult<T> result=new CommonResult<T>();
        result.setData(data);
        result.setCode(200);
        result.setMessage("成功");
        return result;
    }

    public static CommonResult error(Integer code,String msg){
        CommonResult result=new CommonResult();
        result.setCode(code);
        result.setMessage(msg);
        return result;
    }
}